<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class Message extends Model
{
    use HasFactory;
    // 允许批量赋值的字段
    protected $fillable = ['user_id', 'title', 'content'];

    // 定义与 User 的关联（一条留言属于一个用户）
    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class);
    }
}
